
/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2018原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.beans.factory;

/**
 * Interface to be implemented by beans that want to release resources on destruction.
 * A {@link BeanFactory} will invoke the destroy method on individual destruction of a
 * scoped bean. An {@link org.springframework.context.ApplicationContext} is supposed
 * to dispose all of its singletons on shutdown, driven by the application lifecycle.
 *
 * <p>A Spring-managed bean may also implement Java's {@link AutoCloseable} interface
 * for the same purpose. An alternative to implementing an interface is specifying a
 * custom destroy method, for example in an XML bean definition. For a list of all
 * bean lifecycle methods, see the {@link BeanFactory BeanFactory javadocs}.
 *
 * @author Juergen Hoeller
 * @since 12.08.2003
 * @see InitializingBean
 * @see org.springframework.beans.factory.support.RootBeanDefinition#getDestroyMethodName()
 * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#destroySingletons()
 * @see org.springframework.context.ConfigurableApplicationContext#close()
 */
/**
 *要由希望在销毁时释放资源的bean实现的接口。
 *｛@link BeanFactory｝将在
 *作用域bean。假设｛@link.org.springframework.context.ApplicationContext｝
 *在应用程序生命周期的驱动下，在关闭时处理其所有单体。
 *
 *＜p＞Spring托管bean还可以实现Java的｛@link AutoCloseable｝接口
 *出于同样的目的。实现接口的另一种方法是指定
 *自定义销毁方法，例如在XMLbean定义中。对于所有列表
 *bean生命周期方法，请参阅｛@link BeanFactory BeanFactory javadocs｝。
 *
 *@作者Juergen Hoeller
 *@自2003年8月12日
 *@参见InitializingBean
 *@see org.springframework.beans.factory.support.RootBeanDefinition#getDestroyMethodName（）
 *@see org.springframework.beans.factory.config.ConfigableBeanFactory#destroySingletons（）
 *@see org.springframework.context.ConfigurableApplicationContext#close（）
 */
public interface DisposableBean {

	/**
	 * Invoked by the containing {@code BeanFactory} on destruction of a bean.
	 * @throws Exception in case of shutdown errors. Exceptions will get logged
	 * but not rethrown to allow other beans to release their resources as well.
	 */
	/**
	 *在销毁bean时由包含｛@code BeanFactory｝的调用。
	 *如果出现关闭错误，@throws异常。将记录异常
	 *但不允许其他bean也释放其资源。
	 */
	void destroy() throws Exception;

}
